/**
 * 初始化-设备管理
 * @type {string}
 */
var height = $(document.body).height()+"px";
//用react封装
var currentpage = 1,totlepage = 1,i,boxOrdevice="device";//分页的当前页和总的页数
//表单数据：学校页面的对应注解：学校名称 考勤区域  隶属地区 设备自定义套餐（扩展）学校id
var deviceData = [],importDevData = [],batchDataAll = [],saifenData = [],tpfData = [],tpfxData = [],deviceManufactorData = [],importRepeatData = [];//卫小宝的数据、最后一次导入、搜索批号、赛丰智能学生证、2.4G考勤卡、13.56考勤卡、导入出现重复数据
var importDev = {isImportDev:false,deviceType:1};//是否导入,设备类型 1-卫小宝 2-赛丰 4-2.4G考勤卡 3-13.56考勤卡
var schoolData = [];
var deviceCount = 0,allDeviceCount=0; //每个批次下面的设备总量
//左边list的数据、学校列表总数据、显示在下拉框的学校
var listData = [],schoolDataAll = [],schoolDataList = [];
//表单的最高高度、当前第几页、总页数、总行数、设备投放切换、箱号、importRepeatType：1：是智能学生证 2：是考勤卡
var otherData = {maxHeight:'0px',currentpage:0,totlepage:0,totlerows:0,pageLeft:0,pageRight:0,view:'',boxOrdevice:'device',batchNumber:'',upBatchNumber:'',importRepeatType:"1"};
var Page = React.createClass({
    setPage: function (e) {
        setPage($(e.target).html());
        this.props.onPageClick(1);
    },
    showPage: function () {
        showPage();
    },
    render: function () {
        {
            var items = [],
                svar = this;
            if(totlepage == 0 ){
                items.push({num:1,checked:true})
            }else if(totlepage < 6){
                for(i = 1;i <= totlepage ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage >= (totlepage-2)) {//点在左边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                for(i = totlepage-2;i <= totlepage ;i++){
                    if(i == currentpage){
                        items.push({num:i,checked:true})
                    }else{
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage <= 3){
                for(i = 1;i <= 3 ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }else {//点在两边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:currentpage-1,checked:false});
                items.push({num:currentpage,checked:true});
                items.push({num:currentpage+1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }
        }
        return (
            <div className="tableInfo-page">
                <div className="page-number">每页<span className="page-number-list" onClick={this.showPage}>{pagecount}</span>条</div>
                <div className="page-list" style={{top:pageListTop+"px"}}>
                    <ul>
                        {
                            pageList.map(function (item) {
                                return (<li onClick={svar.setPage}>{item}</li>)
                            })
                        }
                    </ul>
                </div>
                <div className="page-limit">
                    <ol className="page-limit-ol">
                        <ol className="page-limit-ol">
                            <li className="page-limit-img" name="-1" onClick={otherData.pageLeft == 0?'':svar.props.onPageClick.bind(svar,-1)}><span className={otherData.pageLeft == 0?'page-limit-left-no':'page-limit-left-yes'}/></li>
                            {
                                items.map(function (item) {
                                    return (<li onClick={isNaN(item.num)?'':svar.props.onPageClick.bind(svar,item.num)} className={item.checked == true?'page-limit-num page-limit-checked':'page-limit-num'} name={item.num}>{item.num}</li>)
                                })
                            }
                            <li className="page-limit-img" name="-2" onClick={otherData.pageRight == 0?'':svar.props.onPageClick.bind(svar,-2)} ><span className={otherData.pageRight == 0?'page-limit-right-no':'page-limit-right-yes'}/></li>
                        </ol>
                    </ol>
                </div>
            </div>
        );
    },
});
//列表的数据
var ListDate = React.createClass({
    render: function () {
        return (
            <li className="list-data-li"  onMouseOver={this.props.onMouseOverList} onMouseOut={this.props.onMouseOutList} >
                <span className="list-number" onClick={this.props.onClickList} title={this.props.batchid}>{this.props.batchid}</span>
                <span className={"list-operation list-operation"+this.props.batchid}>
                    <span className="list-edit"  onClick={this.props.onClickEdit}>编辑</span>
                    <span className="list-delete" onClick={this.props.onClickDelete}>删除</span>
                </span>
            </li>
        );
    }
});
//卫小宝-按箱号
var DeviceBox = React.createClass({
    clickChecked: function () {
        var childsCheckBox = $(".delivery-body").children();
        var b = 0,a = 0;
        for(var i = 0;i<childsCheckBox.length;i++){
            var child = $($(childsCheckBox[i]).children()[0]).children();
            if($(child[0]).length == 0){
                a ++;
            }
            if($(child[0]).is(':checked')){
                b ++;
            }
        };
        if(b == childsCheckBox.length-a){
            $(".boxParentCheckBox").prop('checked',true);
        }else{
            $('.boxParentCheckBox').attr('checked',false);
        }
    },
    render: function () {
        return (
            <tr>
                <td style={{width: '3%'}}><input onClick={this.clickChecked} type="checkbox" className="boxCheckBox" data-status={this.props.status} data-imei={this.props.imei} data-type="1" data-value={this.props.boxid} data-boxid={this.props.boxid} /></td>
                <td style={{width: '10%'}}>{parseInt(this.props.listNumber)+1}</td>
                <td style={{width: '10%'}}>智能学生证</td>
                <td style={{width: '10%'}}>{this.props.factory}</td>
                <td style={{width: '15%'}}>{this.props.boxid}</td>
                <td style={{width: '15%'}}>{this.props.status=="-1"?"未投放":"已投放"}</td>
                <td style={{width: '15%'}}>{this.props.schoolname}</td>
                <td style={{width: '15%'}}>{this.props.devicecounts}</td>
            </tr>
        );
    }
});
//卫小宝-按设备
var Device = React.createClass({
    clickChecked: function () {
        var childsCheckBox = $(".delivery-body").children();
        var b = 0,a = 0;
        for(var i = 0;i<childsCheckBox.length;i++){
            var child = $($(childsCheckBox[i]).children()[0]).children();
            if($(child[0]).length == 0){
                a ++;
            }
            if($(child[0]).is(':checked')){
                b ++;
            }
        };
        if(b == childsCheckBox.length-a){
            $(".deviceParentCheckBox").prop('checked',true);
        }else{
            $('.deviceParentCheckBox').attr('checked',false);
        }
    },
    render: function () {
        return (
            <tr>
                <td style={{width: '3%'}}><input data-status={this.props.status}   onClick={this.clickChecked}  type="checkbox" className="deviceCheckBox" data-imei={this.props.imei} data-type="2" data-value={this.props.id} /></td>
                <td style={{width: '8%'}}>{parseInt(this.props.listNumber)+1}</td>
                <td style={{width: '10%'}}>智能学生证</td>
                <td style={{width: '8%'}}>{this.props.factory}</td>
                <td style={{width: '10%'}}>{this.props.imei}</td>
                <td style={{width: '8%'}}>{this.props.simid == ''?null:this.props.simid}</td>
                <td style={{width: '8%'}}>{this.props.status=="-1"?"未投放":"已投放"}</td>
                <td style={{width: '15%'}}>{this.props.schoolname}</td>
                <td style={{width: '15%'}}>{this.props.batchid}</td>
                <td style={{width: '8%'}}>{this.props.boxid}</td>

            </tr>
        );
    }
});
//考勤卡-拼音的首字母命名
var KQKDevice = React.createClass({
    clickChecked: function () {
        var childsCheckBox = $(".delivery-body").children();
        var b = 0,a = 0;
        for(var i = 0;i<childsCheckBox.length;i++){
            var child = $($(childsCheckBox[i]).children()[0]).children();
            if($(child[0]).length == 0){
                a ++;
            }
            if($(child[0]).is(':checked')){
                b ++;
            }
        };
        if(b == childsCheckBox.length-a){
            $(".deviceParentCheckBox").prop('checked',true);
        }else{
            $('.deviceParentCheckBox').attr('checked',false);
        }
    },
    render: function () {
        {
            var type = false;
            if(this.props.schoolname =="" || this.props.schoolname == null || this.props.schoolname==undefined){
                type = true;
            }
        }
        return (
            <tr>
                <td style={{width: '3%'}}><input data-status={type}  onClick={this.clickChecked}  type="checkbox" className="deviceCheckBox" data-imei={this.props.cardid} data-type="2" data-value={this.props.id} /></td>
                <td style={{width: '5%'}}>{parseInt(this.props.listNumber)+1}</td>
                <td style={{width: '10%'}}>考勤卡</td>
                <td style={{width: '10%'}}>{this.props.factory}</td>
                <td style={{width: '10%'}}>{this.props.cardid}</td>
                <td style={{width: '10%'}}>{type==true?"未投放":"已投放"}</td>
                <td style={{width: '15%'}}>{this.props.schoolname}</td>
            </tr>
        );
    }
});
//赛丰-智能学生卡-拼音的首字母命名
var SFDevice = React.createClass({
    clickChecked: function () {
        var childsCheckBox = $(".delivery-body").children();
        var b = 0,a = 0;
        for(var i = 0;i<childsCheckBox.length;i++){
            var child = $($(childsCheckBox[i]).children()[0]).children();
            if($(child[0]).length == 0){
                a ++;
            }
            if($(child[0]).is(':checked')){
                b ++;
            }
        };
        if(b == childsCheckBox.length-a){
            $(".deviceParentCheckBox").prop('checked',true);
        }else{
            $('.deviceParentCheckBox').attr('checked',false);
        }
    },
    render: function () {
        {
            var type = false;
            if(this.props.schoolname =="" || this.props.schoolname == null || this.props.schoolname==undefined){
                type = true;
            }
        }
        return (
            <tr>
                <td style={{width: '3%'}}><input data-status={type} onClick={this.clickChecked}  type="checkbox" className="deviceCheckBox" data-imei={this.props.imei} data-type="2" data-value={this.props.id} /></td>
                <td style={{width: '8%'}}>{parseInt(this.props.listNumber)+1}</td>
                <td style={{width: '10%'}}>考勤卡</td>
                <td style={{width: '10%'}}>{this.props.factory}</td>
                <td style={{width: '10%'}}>{this.props.imei}</td>
                <td style={{width: '10%'}}>{type==true?"未投放":"已投放"}</td>
                <td style={{width: '16%'}}>{this.props.schoolname}</td>
                <td style={{width: '16%'}}>{this.props.telephone}</td>
            </tr>
        );
    }
});
//导入设备
var ImportDevTable = React.createClass({
    render: function () {
        return (
            <tr>
                <td style={{width: '5%'}}>{parseInt(this.props.listNumber)+1}</td>
                <td style={{width: '10%'}}>{this.props.factory}</td>
                <td style={{width: '10%'}}>{this.props.mdtid}</td>
                <td style={{width: '10%'}}>{this.props.fee}</td>
                <td style={{width: '10%'}}>{this.props.fee2}</td>
                <td style={{width: '10%'}}>{this.props.batchid}</td>
                <td style={{width: '10%'}}>{this.props.boxid}</td>
                <td style={{width: '10%'}}>{this.props.cardid}</td>
                <td style={{width: '15%'}}>{this.props.schoolname}</td>
                <td style={{width: '10%'}}>{this.props.telephone}</td>
            </tr>
        );
    }
});
//新增批号弹出层
var Addbatchnumber = React.createClass({
    onClickHidePop: function () {
        $(".addBatchNumber").hide();
    },
    render: function () {
        return (
            <div  className="pop popPhone addBatchNumber popModel">
                <div className="model"></div>
                <div className="pop-info popModel-info pop-addBatchNumber-info">
                    <div className="pop-title popModel-title">
                        <span className="pop-title-content popModel-title-content">
                            <span className="pop-title-content-solid-left popModel-title-content-solid-left" style={{width: "130px"}} />
                            <span className="batchNumber-title">编辑批号</span>
                            <span className="pop-title-content-solid-right popModel-title-content-solid-right" style={{width: "130px"}} />
                        </span>
                        <span className="pop-title-img popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        <input type="hidden" name="batch_id" id="batch_id"/>
                    </div>
                    <div className="popModel-body">
                        <div className="popModel-body-input">
                            <span className="popModel-body-input-title">批号名</span>
                            <span className="popModel-body-input-content">
                                <input type="hidden" id="oldbatchid" />
                                <input className="input-content " type="text" placeholder="请输入批号" name="batch_batchcode" maxLength="30" id="batch_batchcode"/>
                            </span>
                        </div>
                    </div>
                    <div className="popModel-button" style={{marginTop:'-30px'}}>
                        <span className="popModel-button-ok" onClick={this.props.onClockSaveAddbatchnumber}>保存</span>
                    </div>
                </div>
            </div>
        );
    }
})
//新增设备弹出层
var AddEquipment = React.createClass({
    //关闭弹出层
    onClickHidePop: function () {
        $(".addEquipment").hide();
        $(".errorMsg").hide();
        $("#device_imei").val("");
        $("#device_batchid").val("");
        $("#device_boxid").val("");
    },
    //保存新增设备
    addDevice: function () {
        var param = "",svar = this;
        var device_devicetype = $(".device-devicetype").text();//设备类型
        if(device_devicetype == "考勤卡"){
            device_devicetype = "3";
        }else{
            device_devicetype = "2";//智能学生证
        }
        var device_factory = $(".device-factory").text();//生产商
        var device_imei = $("#device_imei").val();//设备IMEI号
        var device_batchid = $("#device_batchid").val();//批号
        var device_boxid = $("#device_boxid").val();//箱号
        var device_phone = $("#device_phone").val();//设备手机号
        var device_cardid = $("#device_cardid").val();//考勤卡号
        var device_package = $("input[name='devicePackage']:checked").val();//设备套餐(1年或2年)
        var device_fee = $("#device_fee").val();//设备价格
        var device_fee2 = $("#device_fee2").val();//套餐价格
        var add_device_schoolid = $("#add_device_schoolid").val();//选择投放学校
        if(importDev.deviceType == 1){
            var device_telephone = $(".device_telephone").val();//设备手机号
            if(device_imei == ""){
                suixun.alert("设备IMEI号不能为空");
                $(".imei-error").show();
                return;
            }else if(device_imei.length < 14){
                suixun.alert("设备IMEI号格式错误");
                $(".imei-error").show();
                return;
            }
            if(device_batchid == ""){
                suixun.alert("批号不能为空");
                $(".batchid-error").show();
                return;
            }
            if(device_boxid == ""){
                suixun.alert("箱号不能为空");
                $(".boxid-error").show();

                return;
            }
            if(device_telephone != ''){
                if(device_telephone.length != 11){
                    suixun.alert("设备手机号格式错误！");
                    $(".telephone-error").show();
                    return;
                }else if(!/^1[123456789]\d{9}$/.test(device_telephone)){
                    suixun.alert("设备手机号格式错误！");
                    $(".telephone-error").show();
                    return;
                }
            }
            if(device_package == undefined){
                device_package = '';
            }
            device_fee = $(".device_fee").val();//设备价格-卫小宝的是通过class获取
            param="param={";
            param = getJsonDataNotEmpty(param,"devicetype",device_devicetype);
            param = getJsonDataNotEmpty(param,"factory",device_factory);
            param = getJsonDataNotEmpty(param,"imei",device_imei);
            param = getJsonDataNotEmpty(param,"fee",device_fee);
            param = getJsonDataNotEmpty(param,"fee2",device_fee2);
            param = getJsonDataNotEmpty(param,"batchid",device_batchid);
            param = getJsonDataNotEmpty(param,"boxid",device_boxid);
            param = getJsonDataNotEmpty(param,"devicePackage",device_package+'');
            param = getJsonDataNotEmpty(param,"telephone",device_telephone+'');
            param = getJsonDataNotEmpty(param,"type","1");
            param += "}";

        }else if(importDev.deviceType == 2){
            if(device_imei == ""){
                suixun.alert("设备IMEI号不能为空");
                $(".imei-error").show();
                $(".imei-error").show();
                return;
            }else if(device_imei.length != 15){
                suixun.alert("设备IMEI号格式错误");
                $(".imei-error").show();
                return;
            }
            if(device_phone == ""){
                suixun.alert("设备手机号不能为空");
                $(".phone-error").show();
                return;
            }else if(device_phone.length != 11){
                suixun.alert("设备手机号格式错误");
                $(".phone-error").show();
                return;
            }
            if(device_package == undefined){
                device_package = '';
            }
            param="param={";
            param = getJsonDataNotEmpty(param,"devicetype",device_devicetype);
            param = getJsonDataNotEmpty(param,"factory",device_factory);
            param = getJsonDataNotEmpty(param,"imei",device_imei);
            param = getJsonDataNotEmpty(param,"telephone",device_phone);
            param = getJsonDataNotEmpty(param,"fee",device_fee);
            param = getJsonDataNotEmpty(param,"fee2",device_fee2);
            param = getJsonDataNotEmpty(param,"schoolname",add_device_schoolid);
            param = getJsonDataNotEmpty(param,"devicePackage",device_package+'');
            param = getJsonDataNotEmpty(param,"type","2");
            param += "}";
        }else if(importDev.deviceType == 3 || importDev.deviceType == 4){
            if(device_cardid == ""){
                suixun.alert("考勤卡号不能为空");
                $(".cardid-error").show();
                return;
            }else if(device_cardid.length != 10){
                suixun.alert("考勤卡号格式错误");
                $(".cardid-error").show();
                return;
            }
            // if(device_fee == ""){
            //     suixun.alert("设备价格不能为空");
            //     $(".fee-error").show();
            //     return;
            // }
            param="param={";
            param = getJsonDataNotEmpty(param,"devicetype",device_devicetype);
            param = getJsonDataNotEmpty(param,"factory",device_factory);
            param = getJsonDataNotEmpty(param,"cardid",device_cardid);
            param = getJsonDataNotEmpty(param,"fee",device_fee);
            param = getJsonDataNotEmpty(param,"fee2",device_fee2);
            param = getJsonDataNotEmpty(param,"schoolname",add_device_schoolid);
            param = getJsonDataNotEmpty(param,"type",'"'+importDev.deviceType+'"');
            param += "}";
        }
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/deviceInitManage/addDevice.json',param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            if(data!=null && data.code == 200){
                suixun.alert("新增成功",function (isScc) {
                    if(isScc){
                        $("#device_imei").val("");
                        $("#device_batchid").val("");
                        $("#device_boxid").val("");
                        $("#device_cardid").val("");
                        $("#device_phone").val("");
                        $("#device_fee").val("");
                        $(".device_fee").val("");
                        $("#device_fee2").val("");
                        $(".device_telephone").val("");
                        $("input[name='devicePackage']:checked").attr("checked",false);
                        svar.onClickHidePop();
                        svar.props.onPageClick(currentpage);
                        svar.props.queryAllDevice();//查询所有的设备
                    }
                });
            } else {
                suixun.alert((data!=null && data.msg!=null)?data.msg:"新增失败");
            }
        });
    },
    //查询箱号
    onClickPhoneQuery: function (e) {
        suixun.alert("查询箱号")
    },
    //验证
    onBlurInput: function (e) {
        var classname = e.target.getAttribute("data-error");
        if($(e.target).val() == ''){
            $("."+classname+"").show();
        }else{
            $("."+classname+"").hide();
        }
    },
    /**
     * 验证输入框的长度
     * @returns {XML}
     */
    onInputNumber:function (e) {
        var value = e.target.value;
        if(value.length > 10){
            $(e.target).val(value.slice(0,10));
        }
    },
    render: function () {
        return (
            <div  className="pop popPhone addEquipment popModel">
                <div className="model"></div>
                <div className="pop-info popModel-info addEquipment-info">
                    <div className="pop-title popModel-title">
                        <span className="pop-title-content popModel-title-content">
                            <span className="pop-title-content-solid-left popModel-title-content-solid-left" style={{width: "130px"}} />
                                新增设备
                            <span className="pop-title-content-solid-right popModel-title-content-solid-right" style={{width: "130px"}} />
                        </span>
                        <span className="pop-title-img popPhone-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                    </div>
                    <div className="popModel-body">
                        <div className="popModel-body-input" style={{display:"none"}}>
                            <span className="popModel-body-input-title">设备类型</span>
                            <span className="popModel-body-input-content" >
                                <select className="pop-select export-factory" name="device_devicetype" id="device_devicetype">
                                    <option  value="2" selected="selected" >智能学生证</option>
                                    <option value="3" selected="selected" >考勤卡</option>
                                    <option style={{display:"none"}} value="1" >手表</option>
                                </select>
                            </span>
                        </div>
                        <div className="popModel-body-text">
                            <span className="popModel-body-text-title">设备类型</span>
                            <span className="popModel-body-text-content popSeleteImei-address device-devicetype">{importDev.deviceType=="1"?"智能学生证":(importDev.deviceType=="2"?"智能学生证":"考勤卡")}</span>
                        </div>
                        <div className="popModel-body-text">
                            <span className="popModel-body-text-title">生产商</span>
                            <span className="popModel-body-text-content popSeleteImei-address device-factory">{importDev.deviceType=="1"?"卫小宝":(importDev.deviceType=="2"?"赛丰":(importDev.deviceType=="3"?"13.56考勤卡":"2.4G考勤卡"))}</span>
                        </div>
                        <div className="popModel-body-input" style={{display:"none"}}>
                            <span className="popModel-body-input-title">生产商</span>
                            <span className="popModel-body-input-content" >
                                <select className="popModel-select pop-select-supplier" name="device_factory" id="device_factory" >
                                    {
                                        deviceManufactorData.map(function (data) {
                                            return (<option value={data.factory} >{data.factory}</option>)
                                        })
                                    }
                                </select>
                            </span>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="1"?"block":(importDev.deviceType=="2"?"block":"none")}}>
                            <span className="popModel-body-input-title">设备IMEI号</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei" onBlur={this.onBlurInput} id="device_imei" data-error="imei-error" type="text" maxLength="15" placeholder="请输入设备IMEI号" />
                            </span>
                            <div className="errorMsg imei-error" ></div>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="1"?"block":"none"}}>
                            <span className="popModel-body-input-title">批号</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei" onBlur={this.onBlurInput} id="device_batchid" data-error="batchid-error" maxLength="30" type="text" placeholder="请输入设备批号" />
                            </span>
                            <div className="errorMsg batchid-error" ></div>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="1"?"block":"none"}}>
                            <span className="popModel-body-input-title">箱号</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei" onBlur={this.onBlurInput} id="device_boxid" data-error="boxid-error" maxLength="30" type="text" placeholder="请输入箱号" />
                            </span>
                            <div className="errorMsg boxid-error" ></div>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="1"?"block":"none"}}>
                            <span className="popModel-body-input-title noImg">设备手机号</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei device_telephone" onBlur={this.onBlurInput} id="device_telephone " data-error="telephone-error" maxLength="11" type="text" placeholder="请输入设备手机号" />
                            </span>
                        </div>
                        {
                            importDev.deviceType=="1"?
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title" style={{backgroundImage:"url()"}} >设备套餐</span>
                                <span className="popModel-body-radio-content "><input name="devicePackage" value="1" type="radio" /><span>1年</span></span>
                                <span className="popModel-body-radio-content " style={{left:'40px'}}><input name="devicePackage" value="2" type="radio" /><span>2年</span></span>
                            </div>
                                :(importDev.deviceType=="2"?
                                <div className="popModel-body-input">
                                    <span className="popModel-body-input-title" style={{backgroundImage:"url()"}} >设备套餐</span>
                                    <span className="popModel-body-radio-content "><input name="devicePackage" value="1" type="radio" /><span>1年</span></span>
                                    <span className="popModel-body-radio-content " style={{left:'40px'}}><input name="devicePackage" value="2" type="radio" /><span>2年</span></span>
                                </div>
                                :'')
                        }
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="2"?"block":"none"}}>
                            <span className="popModel-body-input-title">设备手机号</span>
                            <span className="popModel-body-input-content">
                                        <input className="input-content export-imei" onBlur={this.onBlurInput} id="device_phone" data-error="phone-error" maxLength="11" type="text" placeholder="请输入设备手机号" />
                                    </span>
                            <div className="errorMsg phone-error" ></div>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="4"?"block":(importDev.deviceType=="3"?"block":"none")}}>
                            <span className="popModel-body-input-title">考勤卡号</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei" onBlur={this.onBlurInput} id="device_cardid" data-error="cardid-error" maxLength="10" type="text" placeholder="请输入考勤卡号" />
                            </span>
                            <div className="errorMsg cardid-error" ></div>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="1"?"block":"none"}}>
                            <span className="popModel-body-input-title" style={{backgroundImage:importDev.deviceType=="1"?"url()":"url(../img/icon/star.png)"}}>设备价格</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei device_fee" onInput={this.onInputNumber} type="number" placeholder="请输入设备价格" />
                            </span>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="1"?"none":"block"}}>
                            <span className="popModel-body-input-title" style={{backgroundImage:"url()"}}>设备价格</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei " onInput={this.onInputNumber} id="device_fee" data-error="fee-error" type="number" placeholder="请输入设备价格" />
                            </span>
                            <div className="errorMsg fee-error" ></div>
                        </div>
                        <div className="popModel-body-input" >
                            <span className="popModel-body-input-title" style={{backgroundImage:"url()"}}>套餐价格</span>
                            <span className="popModel-body-input-content">
                                <input className="input-content export-imei" onInput={this.onInputNumber}  id="device_fee2"  type="number"  placeholder="请输入套餐价格" />
                            </span>
                        </div>
                        <div className="popModel-body-input" style={{display:importDev.deviceType=="1"?"none":"block"}}>
                            <span className="popModel-body-input-title">选择投放学校</span>
                            <span className="popModel-body-input-content pop-addDevice">
                                <select className="popModel-select pop-select-supplier" id="add_device_schoolid" >
                                    {
                                        schoolData.map(function (data) {
                                            return (<option value={data.schoolname} >{data.schoolname}</option>)
                                        })
                                    }
                                </select>
                            </span>
                        </div>
                    </div>
                    <div className="popModel-button" style={{marginTop:"-30px"}}>
                        <span className="popModel-button-ok" onClick={this.addDevice}>确定</span>
                    </div>
                </div>
            </div>
        );
    }
});
//设备投放
var PutDelivery = React.createClass({
    //关闭弹出层
    onClickHidePop: function () {
        $(".popPutDelivery").hide();
    },
    //保存投放
    putDevice: function () {
        suixun.showLoding();//显示加载中
        var svar = this,puttype = "0",putstatus = "2";
        if(importDev.deviceType == 1){
            //赛风、考勤卡
            puttype = "0";
            putstatus = "1";
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolid",$("#device_schoolid").val());
        param = getJsonDataNotEmpty(param,"ids",$("#putdeviceids").val());
        param = getJsonDataNotEmpty(param,"puttype",puttype);
        param = getJsonDataNotEmpty(param,"putstatus",putstatus);
        param += "}";
        suixun.ajax(serverUrl+'/deviceInitManage/putDevice.json',param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            if(data!=null && data.code == 200){
                suixun.alert("投放成功",function (data) {
                    if(data){
                        svar.onClickHidePop();
                        suixun.showLoding();//显示加载中
                        svar.props.onPageClick(currentpage);
                    }
                });
            } else {
                suixun.alert("投放失败");
            }
        });
    },
    render: function () {
        return (
            <div  className="pop popPhone popPutDelivery popModel">
                <div className="model"></div>
                <div className="pop-info popModel-info popPutDelivery-info">
                    <div className="pop-title popModel-title">
                        <span className="pop-title-content popModel-title-content">
                            <span className="pop-title-content-solid-left popModel-title-content-solid-left" style={{width:"135px"}} />
                                设备投放
                            <span className="pop-title-content-solid-right popModel-title-content-solid-right" style={{width:"135px"}} />
                        </span>
                        <span className="pop-title-img popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        <input type="hidden" name="putdeviceids" id="putdeviceids" />
                    </div>
                    <div className="popModel-body">
                        <div className="popModel-body-input">
                            <span className="popModel-body-input-title">选择投放学校</span>
                            <span className="popModel-body-input-content popPutDelivery-select-span">
                                <select className="export-factory" id="device_schoolid" >
                                    {
                                        schoolData.map(function (data) {
                                            return (<option value={data.id} >{data.schoolname}</option>)
                                        })
                                    }
                                </select>
                            </span>
                        </div>
                    </div>
                    <div className="popModel-button" style={{marginTop:"-30px"}}>
                        <span className="popModel-button-ok" onClick={this.putDevice}>确定</span>
                    </div>
                </div>
            </div>
        );
    }
});

//快速投放
var FastDelivery = React.createClass({
    //关闭弹出层
    onClickHidePop: function () {
        $(".popFastDelivery").hide();
    },
    //快速投放
    pubDeviceByBox: function () {
        var svar = this,boxBatchid = $("#boxBatchid").val();
        if(boxBatchid == ""){
        	suixun.alert("请先点击左侧批号！");
        	return;
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolid",$("#box_schoolid").val());
        param = getJsonDataNotEmpty(param,"ids",$("#putboxids").val());
        param = getJsonDataNotEmpty(param,"boxid",'"'+$("#putboxidsBox").val()+'"');
        param = getJsonDataNotEmpty(param,"puttype","1");
        param = getJsonDataNotEmpty(param,"batchid",'"'+boxBatchid+'"');
        param += "}";
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/deviceInitManage/putDevice.json',param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            if(data!=null &&  data.code == 200){
                suixun.alert("投放成功",function (data) {
                    if(data){
                        svar.onClickHidePop();
                        svar.props.onPageClick(currentpage);
                    }
                });
            } else {
                suixun.alert("投放失败");
            }
        });
    },
    //查询箱号
    onClickPhoneQuery: function (e) {
        suixun.alert("查询箱号")
    },
    render: function () {
        return (
            <div  className="pop popPhone popFastDelivery popModel">
                <div className="model"></div>
                <div className="pop-info popModel-info popFastDelivery-info">
                    <div className="pop-title popModel-title">
                        <span className="pop-title-content popModel-title-content">
                            <span className="pop-title-content-solid-left popModel-title-content-solid-left" style={{width:"135px"}} />
                                快速投放
                            <span className="pop-title-content-solid-right popModel-title-content-solid-right" style={{width:"135px"}} />
                        </span>
                        <span className="pop-title-img popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        <input type="hidden" name="putdeviceids" id="putboxids" />
                        <input type="hidden" name="putdeviceids" id="putboxidsBox" />
                        <input type="hidden" name="putdeviceids" id="boxBatchid" />
                    </div>
                    <div className="popModel-body">
                        <div className="popModel-body-input">
                            <span className="popModel-body-input-title">选择投放学校</span>
                            <span className="popModel-body-input-content popFastDelivery-select-span">
                                <select className="export-factory" id="box_schoolid" >
                                    {
                                        schoolData.map(function (data) {
                                            return (<option value={data.id} >{data.schoolname}</option>)
                                        })
                                    }
                                </select>
                            </span>
                        </div>
                    </div>
                    <div className="popModel-button" style={{marginTop:"-30px"}}>
                        <span className="popModel-button-ok" onClick={this.pubDeviceByBox}>确定</span>
                    </div>
                </div>
            </div>
        );
    }
});
//设备投放
var DeviceDelivery = React.createClass({
    /**
     * 调用父组件初始化的查询
     */
    onClickDeviceDelivery:function(){
        this.props.onClickDeviceDelivery();
    },
    /**
     * 调用父组件查询所有的设备
     */
    queryAllDevice: function () {
      this.props.queryAllDevice();
    },
    /**
     * 清空选择框
     */
    resetCleckBox: function () {
        $(".deviceParentCheckBox").attr("checked",false);
        $(".boxCheckBox").attr("checked",false);
        $(".deviceCheckBox").attr("checked",false);
    },
    /**
     * 分页
     * @param num
     */
    onPageClick: function (num) {
        //分页-调用ajac然后把数据查询出来:获取name的值
        //计算currentpage
        suixun.showLoding();//显示加载中
        var onPageLeft = 0,onPageRight = 1,svar = this;
        if(num > 0){
            currentpage = num;
        }else if(num == -1 && currentpage > 1){
            currentpage --;
        }else if(num == -2  && currentpage < totlepage){
            currentpage ++;
        }
        //修改左右的按钮

        if((currentpage == totlepage && totlepage == 1)|| totlepage == 0){
            onPageLeft = 0;
            onPageRight = 0;
        }else if(currentpage == totlepage && totlepage > 1){
            onPageLeft = 1;
            onPageRight = 0;
        }else if(1 < currentpage && currentpage < totlepage){
            onPageLeft = 1;
            onPageRight = 1;
        }

        //判断是不是导入页面
        if(importDev.isImportDev == true){
            importDevData = [];
            var param="param={";
            param = getJsonDataNotEmpty(param,"pagenumber",""+currentpage+"");
            param = getJsonDataNotEmpty(param,"pagecount",""+pagecount+"");
            param += "}";
            suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceTmpList.json',param,"get",function(data){
                suixun.hideLoding();//隐藏加载中
                if(data.code == 200){
                    if( data.info.queryresult != null ){
                        for(var i=0;i<data.info.queryresult.length;i++){
                            var obj=data.info.queryresult[i];
                            importDevData[i] = {id:i,factory:obj.factory,mdtid:obj.mdtid,fee:obj.fee,fee2:obj.fee2,batchid:obj.batchid,boxid:obj.boxid,cardid:obj.cardid,schoolname:obj.schoolname,telephone:obj.telephone};
                        }
                    }
                    if(data.info.totlepage > 1 && data.info.totlepage > currentpage){
                        onPageRight = 1
                    }else{
                        onPageRight = 0;
                    }
                    otherData.totlepage = data.info.totlepage;
                    otherData.totlerows = data.info.totlerows;
                    otherData.pageLeft = onPageLeft;
                    otherData.pageRight = onPageRight;
                    otherData.currentpage = currentpage;
                    totlepage = data.info.totlepage;//初始化的时候赋值：分页的当前页和总的页数
                    svar.setState({importDevData:importDevData,otherData:otherData});

                }
                leftList();//设置左侧批号高度
            });
        }else{
            var index = importDev.deviceType;
            var param="param={pagenumber:"+currentpage+",pagecount:"+pagecount;
            param = getJsonDataNotEmpty(param,"type",'"'+index+'"');
            param = getJsonDataNotEmpty(param,"batchid",'"'+$("#device-batchid").val()+'"');
            if($("#device-status").val() != "99"){
                param = getJsonDataNotEmpty(param,"status",'"'+$("#device-status").val()+'"');
            }
            if($(".left-election-value").html()=="按设备" && importDev.deviceType=="1"){
                param = getJsonDataNotEmpty(param,"showtype",'"1"');
            }else if($(".left-election-value").html()=="按箱号" && importDev.deviceType=="1"){
                param = getJsonDataNotEmpty(param,"showtype",'"2"');
            }
            if($(".school-or-table").html() == '学校'){
                param = getJsonDataNotEmpty(param,"schoolname",'"'+$("#schoolname_search").val()+'"');
            }else{
                param = getJsonDataNotEmpty(param,"imei",'"'+$("#schoolname_search").val()+'"');
            }
            param += "}";
            suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceInitList.json',param,"get",function(data){
                suixun.hideLoding();//隐藏加载中
                svar.resetCleckBox();//清空选择框
                if(data.code == 200){
                    deviceData = [];
                    tpfxData = [];
                    saifenData = [];
                    tpfData = [];
                    if(index == "1"){//卫小宝
                        for(var i=0;i<data.info.queryresult.length;i++){
                            var obj=data.info.queryresult[i];
                            deviceData[i] = {id:obj.id,devicetype:obj.devicetype,simid:obj.simid,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,batchid:obj.batchid,boxid:obj.boxid,devicecounts:obj.devicecounts};
                        }
                    }else if(index == "2"){//赛丰
                        for(var i=0;i<data.info.queryresult.length;i++){
                            var obj=data.info.queryresult[i];
                            saifenData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,telephone:obj.telephone,devicecounts:obj.devicecounts};
                        }
                    }else if( index == "4"){// 2.4G考勤卡
                        for(var i=0;i<data.info.queryresult.length;i++){
                            var obj=data.info.queryresult[i];
                            tpfData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,cardid:obj.cardid,status:obj.status,schoolname:obj.schoolname,devicecounts:obj.devicecounts};
                        }
                    }else if(index == "3" ){//13.56考勤卡
                        for(var i=0;i<data.info.queryresult.length;i++){
                            var obj=data.info.queryresult[i];
                            tpfxData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,cardid:obj.cardid,status:obj.status,schoolname:obj.schoolname,devicecounts:obj.devicecounts};
                        }
                    }
                    if(data.info.totlepage > 1 && data.info.totlepage > currentpage){
                        onPageRight = 1
                    }else{
                        onPageRight = 0;
                    }
                    otherData = {maxHeight:height,currentpage:currentpage,totlepage:data.info.totlepage,totlerows:data.info.totlerows,pageLeft:onPageLeft,pageRight:onPageRight,view:'deviceDelivery',boxOrdevice:boxOrdevice,batchNumber:$("#device-batchid").val(),upBatchNumber:''};
                    totlepage = data.info.totlepage;//初始化的时候赋值：分页的当前页和总的页数
                    svar.setState({deviceData:deviceData,otherData:otherData,saifenData:saifenData,tpfxData:tpfxData,tpfData:tpfData});
                }
                leftList();//设置左侧批号高度
            });

        }
    },
    onMouseOverList: function (batchid) {
        $(".list-operation"+batchid+"").show();
    },
    onMouseOutList: function (batchid) {
        $(".list-operation"+batchid+"").hide();
    },
    //左边列表编辑按钮
    onClickEdit: function (info) {
        $("#batch_id").val(info[0]);
        $("#batch_batchcode").val(info[1]);
        $("#oldbatchid").val(info[1]);
        $(".batchNumber-title").html("编辑批号");
        $(".addBatchNumber").show();
    },
    //左边列表删除按钮
    onClickDelete: function (batchid) {
        var svar = this;
        suixun.confirm_noTit("你确定要删除该批次吗？",function (data) {
            if (data == true) {
                suixun.showLoding();//显示加载中
                var url = serverUrl + '/batchManage/deleteBatch.json';
                var param = "param={";
                param = getJsonDataNotEmpty(param, "id", batchid + "");
                param += "}";
                suixun.ajax(url,param,"get",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if (data != null && data.code != null && data.code == 200) {
                        suixun.alert("操作成功",function (data) {
                            if(data){
                                suixun.showLoding();//显示加载中
                                listData = [];
                                suixun.ajax(serverUrl + '/batchManage/queryBatch.json','',"get",function(data){
                                    for (var i = 0; i < data.info.length; i++) {
                                        var obj = data.info[i];
                                        listData[i] = {id: obj.id, batchid: obj.batchid};
                                    }
                                    svar.setState({listData: listData});
                                    suixun.hideLoding();//隐藏加载中
                                });
                            }
                        });
                    } else {
                        suixun.alert((data != null && data.msg != null) ? data.msg : "操作失败");
                    }
                });
            }
        });
    },
    //点击新增批号
    onClickAddBatch: function () {
        $("#batch_id").val("");
        $("#batch_batchcode").val("");
        $(".batchNumber-title").html("新增批号");
        $(".addBatchNumber").show();
    },
    //保存新增批号
    onClockSaveAddbatchnumber: function () {
        var svar = this;
        var id=$("#batch_id").val(),batch_batchcode = $("#batch_batchcode").val();
        if(batch_batchcode == ""){
            suixun.alert("批号不能为空!");
            return;
        }else if(!/^[^\u4e00-\u9fa5]{0,}$/.test(batch_batchcode)){
            suixun.alert("批号格式错误!");
            return;
        }
        $(".addBatchNumber").hide();
        var url=serverUrl+'/batchManage/addBatch.json';
        var param="param={";
        if(id!=null && id!=""){
            param = getJsonDataNotEmpty(param,"id",$("#batch_id").val());
            url=serverUrl+'/batchManage/modifyBatch.json';
        }
        param = getJsonDataNotEmpty(param,"batchid",'"'+batch_batchcode+'"');
        param = getJsonDataNotEmpty(param,"oldbatchid",'"'+$("#oldbatchid").val()+'"');
        param += "}";
        suixun.showLoding();//显示加载中
        suixun.ajax(url,param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            if(data!=null && data.code == 200){
                suixun.alert("操作成功",function (data) {
                    if(data){
                        //编辑批号，成功就会更新右侧数据
                        if(id!=null && id!=""){
                            svar.onClickList([batch_batchcode]);
                            setTimeout(function () {
                                var listDataUl = $(".list-data-ul").children();//批号列表
                                for(var i = 0;i<listDataUl.length;i++){
                                    if($(listDataUl[i]).find(".list-number").html() == batch_batchcode){
                                        $('.list-data').animate({
                                            scrollTop: 60+i*25//$(listDataUl[i]).offset().top-60
                                        }, 200);
                                        $(".list-data-div").siblings().removeClass(" select");
                                        $(listDataUl[i]).addClass(" select").siblings().removeClass(" select");
                                        //设置批号编号
                                        $("#device-batchid").val(batch_batchcode);
                                        break;
                                    }
                                }
                            },200);
                        }
                        suixun.showLoding();//显示加载中
                        $(".list-data-div-ul").show();
                        listData = [];
                        suixun.ajax(serverUrl+'/batchManage/queryBatch.json','',"get",function(data){
                            suixun.hideLoding();//隐藏加载中
                            if(data.code == 200){
                                for(var i=0;i<data.info.length;i++){
                                    var obj=data.info[i];
                                    listData[i] = {id:obj.id,batchid:obj.batchid};
                                }
                                svar.setState({listData:listData});
                            }
                        });
                    }
                });
            } else {
                suixun.alert((data!=null && data.msg!=null)?data.msg:"操作失败");
            }
        });
    },
    //点击左边的列表
    onClickList: function (info) {
        suixun.showLoding();//显示加载中
        $("#device-batchid").val(info[0]);
        $("#boxBatchid").val(info[0]);//按箱号快速投放
        $("#device-status").val("");
        deviceData = [];
        var param="param={";
        param = getJsonDataNotEmpty(param,"batchid",'"'+info[0]+'"');
        if($("#device-status").val() != "99"){
            param = getJsonDataNotEmpty(param,"status",'"'+$("#device-status").val()+'"');
        }
        if($(".left-election-value").html()=="按设备" && importDev.deviceType=="1"){
            param = getJsonDataNotEmpty(param,"showtype",'"1"');
        }else if($(".left-election-value").html()=="按箱号" && importDev.deviceType=="1"){
            param = getJsonDataNotEmpty(param,"showtype",'"2"');
        }
        if($(".school-or-table").html() == '学校'){
            param = getJsonDataNotEmpty(param,"schoolname",'"'+$("#schoolname_search").val()+'"');
        }else{
            param = getJsonDataNotEmpty(param,"imei",'"'+$("#schoolname_search").val()+'"');
        }
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+"");
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceInitList.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            svar.resetCleckBox();//清空选择框
            if(data.code == 200){
                for(var i=0;i<data.info.queryresult.length;i++){
                    var obj=data.info.queryresult[i];
                    deviceData[i] = {id:obj.id,devicetype:obj.devicetype,simid:obj.simid,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,batchid:obj.batchid,boxid:obj.boxid,devicecounts:obj.devicecounts};
                }
                var pageRight = 0;
                if(data.info.totlepage > 1){
                    pageRight = 1
                }
                otherData = {maxHeight:height,currentpage:1,totlepage:data.info.totlepage,totlerows:data.info.totlerows,pageLeft:0,pageRight:pageRight,view:'deviceDelivery',boxOrdevice:boxOrdevice,batchNumber:info[0],upBatchNumber:''};
                currentpage = 1;totlepage = data.info.totlepage;//初始化的时候赋值：分页的当前页和总的页数
                if(data.info.queryparam.boxRows!=null){
                    deviceCount=data.info.queryparam.boxRows;
                }else{
                    deviceCount=data.info.totlerows;
                }
                importDev.deviceType = "1";
                svar.setState({deviceData:deviceData,otherData:otherData,deviceCount:deviceCount,importDev:importDev});
            }
        });
    },
    //点击类别
    onClickCategory: function (e) {
        var value = e.target.innerHTML,svar = this;
        suixun.showLoding();//显示加载中
        if(value == "按箱号"){
            otherData.boxOrdevice = "box";
            $("#showtype").val("2");
            $("#device-status").val("");
            deviceData = [];
            var param="param={";
            param = getJsonDataNotEmpty(param,"batchid",'"'+$("#device-batchid").val()+'"');
            if($("#device-status").val() != "99"){
                param = getJsonDataNotEmpty(param,"status",'"'+$("#device-status").val()+'"');
            }
            param = getJsonDataNotEmpty(param,"showtype",'"2"');
            if($(".school-or-table").html() == '学校'){
                param = getJsonDataNotEmpty(param,"schoolname",'"'+$("#schoolname_search").val()+'"');
            }else{
                param = getJsonDataNotEmpty(param,"imei",'"'+$("#schoolname_search").val()+'"');
            }
            param = getJsonDataNotEmpty(param,"pagecount",pagecount+"");
            param += "}";
            suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceInitList.json',param,"get",function(data){
                suixun.hideLoding();//隐藏加载中
                svar.resetCleckBox();//清空选择框
                if(data.code == 200){
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        deviceData[i] = {id:obj.id,devicetype:obj.devicetype,simid:obj.simid,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,batchid:obj.batchid,boxid:obj.boxid,devicecounts:obj.devicecounts};
                    }
                    var pageRight = 0;
                    if(data.info.totlepage > 1){
                        pageRight = 1
                    }
                    otherData = {maxHeight:height,currentpage:1,totlepage:data.info.totlepage,totlerows:data.info.totlerows,pageLeft:0,pageRight:pageRight,view:'deviceDelivery',boxOrdevice:"box",batchNumber:$("#device-batchid").val(),upBatchNumber:''};
                    currentpage = 1,totlepage = data.info.totlepage;boxOrdevice="box";//初始化的时候赋值：分页的当前页和总的页数
                    deviceCount=data.info.queryparam.boxRows;
                    svar.setState({deviceData:deviceData,otherData:otherData,deviceCount:deviceCount});
                    leftList();//设置左侧批号高度
                }
            });
        }else {
            otherData.boxOrdevice = "device";
            $("#showtype").val("1");
            deviceData = [];
            var param="param={";
            param = getJsonDataNotEmpty(param,"batchid",'"'+$("#device-batchid").val()+'"');
            if($("#device-status").val() != "99"){
                param = getJsonDataNotEmpty(param,"status",'"'+$("#device-status").val()+'"');
            }
            param = getJsonDataNotEmpty(param,"showtype",'"1"');
            if($(".school-or-table").html() == '学校'){
                param = getJsonDataNotEmpty(param,"schoolname",'"'+$("#schoolname_search").val()+'"');
            }else{
                param = getJsonDataNotEmpty(param,"imei",'"'+$("#schoolname_search").val()+'"');
            }
            param = getJsonDataNotEmpty(param,"pagecount",pagecount+"");
            param += "}";
            suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceInitList.json',param,"get",function(data){
                suixun.hideLoding();//隐藏加载中
                svar.resetCleckBox();//清空选择框
                if(data.code == 200){
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        deviceData[i] = {id:obj.id,devicetype:obj.devicetype,simid:obj.simid,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,batchid:obj.batchid,boxid:obj.boxid,devicecounts:obj.devicecounts};
                    }
                    var pageRight = 0;
                    if(data.info.totlepage > 1){
                        pageRight = 1
                    }
                    otherData = {maxHeight:height,currentpage:1,totlepage:data.info.totlepage,totlerows:data.info.totlerows,pageLeft:0,pageRight:pageRight,view:'deviceDelivery',boxOrdevice:"device",batchNumber:$("#device-batchid").val(),upBatchNumber:''};
                    currentpage = 1,totlepage = data.info.totlepage,boxOrdevice="device";//初始化的时候赋值：分页的当前页和总的页数
                    deviceCount=data.info.totlerows;
                    svar.setState({deviceData:deviceData,otherData:otherData,deviceCount:deviceCount});
                    leftList();//设置左侧批号高度
                }
            });
        }
        //this.setState({otherData:otherData,tableData:tableData});
        $(".drop-down").slideUp();
    },
    //批量导入Excel
    onClickImportExport: function() {
        $(".excelInput").show();
    },
    //导入保存的按钮
    excelInput: function () {
        var svar = this;
        var file_name = $(".file_name").val();
        if(file_name != ""){
            suixun.showLoding();//显示加载中
            var formData=new FormData($("#excelInputFrom")[0]);
            suixun.ajax(serverUrl+'/deviceInitManage/importDevice.json',formData,"post",function(data){
                suixun.hideLoding(200);//隐藏加载中
                if(data.code == 200 && data.info == null){//成功
                    suixun.alert('导入成功',function (data) {
                        if(data){
                            $(".excelInput").hide();
                            svar.onClickQueryLastDev();
                            svar.queryAllDevice();//查询所有的设备
                            //查询批号
                            suixun.ajax(serverUrl+'/batchManage/queryBatch.json','',"get",function(data){
                                if(data.code == 200){
                                    for(var i=0;i<data.info.length;i++){
                                        var obj=data.info[i];
                                        listData[i] = {id:obj.id,batchid:obj.batchid};
                                    }
                                    svar.setState({listData:listData});
                                }
                            });
                        }
                    })
                }else if(data.code == 200 && data.info != null){//有重复数据
                    suixun.alert('此次导入有重复数据！',function (data) {
                        if(data){
                            $(".excelInput").hide();
                            $(".popImportRepeat").show();
                        }
                    });
                    if(data.info[0].cardid == null){
                        otherData.importRepeatType = "1";
                    }else{
                        otherData.importRepeatType = "2";
                    }
                    importRepeatData = data.info;
                    svar.setState({importRepeatData:importRepeatData,otherData:otherData});
                }else{
                    suixun.alert(data.msg);
                }
            });
        }else{
            suixun.alert("请选择上传文件!");
        }
    },
    //筛选是否投放
    onClickIsPutIn: function (e) {
        suixun.showLoding();//显示加载中
        var elm = e.target,index = importDev.deviceType,svar = this;
        deviceData = [];
        $("#device-status").val($(elm).attr("data-status"));
        $(".right-election-value").html(elm.innerHTML);//赋值
        var param="param={";
        param = getJsonDataNotEmpty(param,"batchid",'"'+$("#device-batchid").val()+'"');
        if($("#device-status").val() != "99"){
            param = getJsonDataNotEmpty(param,"status",'"'+$("#device-status").val()+'"');
        }
        if($(".left-election-value").html()=="按设备" && importDev.deviceType=="1"){
            param = getJsonDataNotEmpty(param,"showtype",'"1"');
        }else if($(".left-election-value").html()=="按箱号" && importDev.deviceType=="1"){
            param = getJsonDataNotEmpty(param,"showtype",'"2"');
        }
        if($(".school-or-table").html() == '学校'){
            param = getJsonDataNotEmpty(param,"schoolname",'"'+$("#schoolname_search").val()+'"');
        }else{
            param = getJsonDataNotEmpty(param,"imei",'"'+$("#schoolname_search").val()+'"');
        }
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+"");
        param = getJsonDataNotEmpty(param,"type",'"'+index+'"');
        param += "}";
        suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceInitList.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            svar.resetCleckBox();//清空选择框
            if(data.code == 200){
                deviceData = [];
                tpfxData = [];
                saifenData = [];
                tpfData = [];
                if(index == "1"){//卫小宝
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        deviceData[i] = {id:obj.id,devicetype:obj.devicetype,simid:obj.simid,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,batchid:obj.batchid,boxid:obj.boxid,devicecounts:obj.devicecounts};
                    }
                }else if(index == "2"){//赛丰
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        saifenData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,telephone:obj.telephone,devicecounts:obj.devicecounts};
                    }
                }else if( index == "4"){// 2.4G考勤卡
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        tpfData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,cardid:obj.cardid,status:obj.status,schoolname:obj.schoolname,devicecounts:obj.devicecounts};
                    }
                }else if(index == "3" ){//13.56考勤卡
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        tpfxData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,cardid:obj.cardid,status:obj.status,schoolname:obj.schoolname,devicecounts:obj.devicecounts};
                    }
                }
                var pageRight = 0;
                if(data.info.totlepage > 1){
                    pageRight = 1;
                }
                otherData = {maxHeight:height,currentpage:1,totlepage:data.info.totlepage,totlerows:data.info.totlerows,pageLeft:0,pageRight:pageRight,view:'deviceDelivery',boxOrdevice:boxOrdevice,batchNumber:$("#device-batchid").val(),upBatchNumber:''};
                currentpage = 1;totlepage = data.info.totlepage;//初始化的时候赋值：分页的当前页和总的页数
                svar.setState({deviceData:deviceData,otherData:otherData,saifenData:saifenData,tpfxData:tpfxData,tpfData:tpfData});
                $(".drop-down").slideUp();
            }
        });
    },
    /**
     * 投放按设备-考勤卡、赛风也可以投放
     * data-status：卫小宝（-1：未投放）、考勤卡，赛风（true：未投放）
     * @returns {boolean}
     */
    onClickPutInEquipment: function () {
        var idList="";
        if(importDev.deviceType == 1){
            $(".deviceCheckBox").each(function(i,box) {
                if((box!=null && box.checked)&&($(box).attr("data-status")==-1)){
                    idList+=$(box).attr("data-value")+"|";
                }
            });
        }else{
            $(".deviceCheckBox").each(function(i,box) {
                console.log($(box).attr("data-status"));
                if((box!=null && box.checked)&&($(box).attr("data-status")=="true")){
                    idList+=$(box).attr("data-value")+"|";
                }
            });
        }

        if(idList.length>1){
            idList=idList.substring(0,idList.length-1);
            $("#putdeviceids").val(idList);
        }else{
            suixun.alert("请选择未投放的设备");
            return false;
        }
        $(".popPutDelivery").show();
    },
    //新增设备
    onClickAddEquipment: function () {
        var index = importDev.deviceType;
        if(index == "1"){//卫小宝
            var batchid=$("#device-batchid").val();
            if(batchid==null || batchid==""){
                suixun.alert("请先选择左边的批号");
                return false;
            }
            $("#device_batchid").val($("#device-batchid").val());
        }
        $(".addEquipment").show();
    },
    //快速投放
    onClickSpeedinessPutIn: function () {
        var idList="",putboxidsBox = "";
        
        $(".boxCheckBox").each(function(i,box) {
            if(box!=null && box.checked)
                idList+=$(box).attr("data-value")+"|";
            	putboxidsBox+=$(box).attr("data-boxid")+",";
        });

        if(idList.length>1){
            idList=idList.substring(0,idList.length-1);
            putboxidsBox=putboxidsBox.substring(0,putboxidsBox.length-1);
            $("#putboxids").val(idList);
            $("#putboxidsBox").val(putboxidsBox);
        }else{
            suixun.alert("请先选择要投放的箱号");
            return false;
        }
        $(".popFastDelivery").show();
    },
    onClickAll: function (info) {
        info[0]=null;
        this.onClickList(info);
    },
    //查询最后一次入库
    onClickQueryLastDev: function () {
        suixun.showLoding();//显示加载中
        importDevData = [];
        importDev.isImportDev = true;
        this.setState({importDev:importDev});
        var param="param={";
        param = getJsonDataNotEmpty(param,"pagenumber","1");
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+'');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceTmpList.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                if( data.info.queryresult != null ){
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        importDevData[i] = {id:i,factory:obj.factory,mdtid:obj.mdtid,fee:obj.fee,fee2:obj.fee2,batchid:obj.batchid,boxid:obj.boxid,cardid:obj.cardid,schoolname:obj.schoolname,telephone:obj.telephone};
                    }
                }
                otherData.totlepage = data.info.totlepage;
                otherData.totlerows = data.info.totlerows;
                otherData.pageLeft = 0;
                if(data.info.totlepage > 1){
                    otherData.pageRight = 1;
                }else{
                    otherData.pageRight = 0;
                }
                otherData.currentpage = 1;
                currentpage = 1;
                totlepage = data.info.totlepage;//初始化的时候赋值：分页的当前页和总的页数
                svar.setState({importDevData:importDevData,otherData:otherData});
            }
        });
    },
    //返回
    onClickReturn: function () {
        $(".right-election-value").html("筛选");
        importDev.isImportDev = false;
        this.setState({importDev:importDev});
        this.queryDevide( importDev.deviceType);

    },
    //撤销操作
    onClickRevoke: function () {
        var svar = this;
        suixun.confirm_noTit("是否撤销数据！",function (data) {
           if(data){
               suixun.showLoding();//显示加载中
               suixun.ajax(serverUrl+'/deviceInitManage/cancelDeviceImport.json','',"get",function(data){
                   suixun.hideLoding(200);//隐藏加载中
                   if(data.code == 200){
                       suixun.alert(data.info,function (data) {
                           if(data){
                               svar.onClickReturn();
                               svar.queryAllDevice();//查询所有的设备
                           }
                       })
                   }else{
                       suixun.alert(data.msg);
                   }
               });
           }
        });
    },
    //鼠标移上卫小宝
    onMouseMoveWxb: function () {
        $(".wxbAdd").show();
    },
    //鼠标移出卫小宝
    onMouseOutWxb: function () {
        $(".wxbAdd").hide();
    },

    //改变弹出层批号输入框
    onChangBatchInput: function (e) {
        var val = $(e.target).val();
        if(val != ""){
            this.batchArray(val,$(e.target).attr("data-list"));
        }else{
            $("."+$(e.target).attr("data-list")+"").hide();
        }
    },
    //排序
    batchArray: function (val,cls) {
        batchDataAll = [];
        for(var i = 0;i < listData.length;i++){
            if((listData[i].batchid).indexOf(val) >= 0){
                batchDataAll.push({batchid:listData[i].batchid});
            }
        }
        if(batchDataAll.length == 0){
            $("."+cls+"").hide();
        }else{
            $("."+cls+"").show();
            this.setState({batchDataAll:batchDataAll});
        }
    },
    onClickBatch: function (e) {
        var val = $(e.target).val();
        this.batchArray(val,$(e.target).attr("data-list"));
    },
    //点击卫小宝、赛丰、2.4G考勤卡、13.56考勤卡
    onClickDevice: function (e) {
        var svar = this;
        suixun.showLoding();//显示加载中
        var index = $(e.target).attr("data-deviceType");
        setTimeout(function () {
            svar.onClickDevice_DOM(index);
        },200);

       $("#boxBatchid").val("");//清空按箱号-快速投放
    },
    onClickDevice_DOM: function (index) {
        $("#device-batchid").val("");
        $(".list-number-span").removeClass(" select");
        //挡批号只有一个的时候会出现一个bug那一个用siblings()无法删除
        if($(".list-data-li").length == 1){
            $(".list-data-li").removeClass(" select");
        }else{
            $(".list-data-li").siblings().removeClass(" select");
        }
        if(index == "1"){
            this.weixbIsHide();//收缩批号列表
        }
        $(".right-election-value").html("筛选");
        this.queryDevide(index);
    },
    /**
     * 收缩批号列表
     */
    weixbIsHide:function () {
        if($(".list-data-div-ul").is(":hidden")){
            this.listOpen();
        }else{
            this.listOut();
        }
    },
    //卫小宝展开
    listOpen: function () {
        $(".list-data-ul").slideDown(200);
    },
    //卫小宝收回
    listOut: function () {
        $(".list-data-ul").slideUp(200);
    },
    queryDevide: function (index) {
        suixun.showLoding();//显示加载中
        importDev.deviceType = index;
        importDev.isImportDev = false;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+index+'"');
        param = getJsonDataNotEmpty(param,"batchid",$("#device-batchid").val());
        param = getJsonDataNotEmpty(param,"pagenumber","1");
        if($(".school-or-table").html() == '学校'){
            param = getJsonDataNotEmpty(param,"schoolname",'"'+$("#schoolname_search").val()+'"');
        }else{
            param = getJsonDataNotEmpty(param,"imei",'"'+$("#schoolname_search").val()+'"');
        }
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+'');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceInitList.json',param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            deviceData = [];
            tpfxData = [];
            saifenData = [];
            tpfData = [];
            svar.resetCleckBox();//清空选择框
            if(data.code == 200){
                if(index == "1"){//卫小宝
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        deviceData[i] = {id:obj.id,devicetype:obj.devicetype,simid:obj.simid,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,batchid:obj.batchid,boxid:obj.boxid,devicecounts:obj.devicecounts};
                    }
                }else if(index == "2"){//赛丰
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        saifenData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,telephone:obj.telephone,devicecounts:obj.devicecounts};
                    }
                }else if( index == "4"){// 2.4G考勤卡
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        tpfData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,cardid:obj.cardid,status:obj.status,schoolname:obj.schoolname,devicecounts:obj.devicecounts};
                    }
                }else if(index == "3" ){//13.56考勤卡
                    for(var i=0;i<data.info.queryresult.length;i++){
                        var obj=data.info.queryresult[i];
                        tpfxData[i] = {id:obj.id,devicetype:obj.devicetype,factory:obj.factory,cardid:obj.cardid,status:obj.status,schoolname:obj.schoolname,devicecounts:obj.devicecounts};
                    }
                }
                var pageRight = 0;
                if(data.info.totlepage > 1){
                    pageRight = 1;
                }
                otherData = {maxHeight:height,currentpage:1,totlepage:data.info.totlepage,totlerows:data.info.totlerows,pageLeft:0,pageRight:pageRight,view:'deviceDelivery',boxOrdevice:"device",batchNumber:'',upBatchNumber:''};
                currentpage = 1;totlepage = data.info.totlepage;boxOrdevice="device";//初始化的时候赋值：分页的当前页和总的页数
                deviceCount=data.info.totlerows;
                $("#device-batchid").val("");//清空保存的批号
                svar.setState({deviceData:deviceData,otherData:otherData,deviceCount:deviceCount,importDev:importDev,saifenData:saifenData,tpfxData:tpfxData,tpfData:tpfData});
                leftList();//计算左侧高度
            }else{
                otherData = {maxHeight:height,currentpage:1,totlepage:1,totlerows:1,pageLeft:0,pageRight:pageRight,view:'deviceDelivery',boxOrdevice:"device",batchNumber:'',upBatchNumber:''};
                currentpage = 1;totlepage =1;boxOrdevice="device";//初始化的时候赋值：分页的当前页和总的页数
                deviceCount=1;
                svar.setState({deviceData:deviceData,otherData:otherData,deviceCount:deviceCount,importDev:importDev,saifenData:saifenData,tpfxData:tpfxData,tpfData:tpfData});
                leftList();//计算左侧高度
            }
        });
    },
    //点击图片搜索
    onClickQueryImg: function(){
        var batchcode = $("#batchcode").val();
        for(var i = 0;i < listData.length;i++){//看批号数据里面有没有输入的批号
            if(listData[i].batchid == batchcode){
                batchDataAll.push({batchid:listData[i].batchid});
                $(".batchList").hide();//隐藏批号列表
                var listDataUl = $(".list-data-ul").children();//批号列表
                for(var i = 0;i<listDataUl.length;i++){
                    if($(listDataUl[i]).find(".list-number").html() == batchcode){
                        if($(".list-data-div-ul").is(":hidden")){
                            this.listOpen();
                        }
                        $('.list-data').animate({
                            scrollTop: 60+i*25//$(listDataUl[i]).offset().top-60
                        }, 100);
                        $(".list-data-div").siblings().removeClass(" select");
                        $(listDataUl[i]).addClass(" select").siblings().removeClass(" select");
                        //设置批号编号
                        $("#device-batchid").val(batchcode);
                        this.queryDevide(1);
                        break;
                    }
                }
                return;
            }
        }
    },
    //点击左侧搜索下拉列表
    onClickBachIdList: function (e) {
        var target = $(e.target);
        $("#batchcode").val(target.html());
        $(".batchList").hide();//隐藏批号列表
        var listDataUl = $(".list-data-ul").children();//批号列表
        for(var i = 0;i<listDataUl.length;i++){
            if($(listDataUl[i]).find(".list-number").html() == target.html()){
                if($(".list-data-div-ul").is(":hidden")){
                    this.listOpen();
                }
                $('.list-data').animate({
                    scrollTop: 60+i*25//$(listDataUl[i]).offset().top-60
                }, 100);
                $(".list-data-div").siblings().removeClass(" select");
                $(listDataUl[i]).addClass(" select").siblings().removeClass(" select");
                //设置批号编号
                $("#device-batchid").val(target.html());
                this.queryDevide(1);
                break;
            }
        }
    },
    /**
     * 改变弹出层学校输入框
     * @param e
     */
    onChangSchoolInput: function (e) {
        if($('.school-or-table').html() == 'IMEI号'){
            return;
        }
        var val = $(e.target).val();
        if(val != ""){
            this.schoolArray(val,$(e.target).attr("data-list"));
        }else{
            $("."+$(e.target).attr("data-list")+"").hide();
        }
    },
    /**
     * 搜索学校排序
     * @param val
     * @param cls
     */
    schoolArray: function (val,cls) {
        schoolDataList = [];
        for(var i = 0;i < schoolDataAll.length;i++){
            if((schoolDataAll[i].schoolname).indexOf(val) >= 0){
                schoolDataList.push({schoolname:schoolDataAll[i].schoolname});
            }
        }
        if(schoolDataList.length == 0){
            $("."+cls+"").hide();
        }else{
            $("."+cls+"").show();
            this.setState({schoolDataList:schoolDataList});
        }
    },
    /**
     * 点击学校输入框
     * @param e
     */
    onClickDropQuery: function (e) {
        if($('.school-or-table').html() == 'IMEI号'){
            return;
        }
        var val = $(e.target).val();
        this.schoolArray(val,$(e.target).attr("data-list"));
    },
    /**
     * 更具学校搜索
     */
    onClickQuerySchoolName: function () {
        this.onPageClick(currentpage);
    },
    /**
     *点击搜索学校的下拉框内容
     *
     */
    onClickQuerySchoolList: function (e) {
        $("#schoolname_search").val($(e.target).html());
        this.onClickQuerySchoolName();
    },
    /**
     * 回收
     */
    onClickRecovery: function () {
        var idList="",svar = this;
        if(importDev.deviceType == 1){
            $(".deviceCheckBox").each(function(i,box) {
                if((box!=null && box.checked)&&($(box).attr("data-status")!=-1)){
                    idList+=$(box).attr("data-imei")+",";
                }
            });
        }else{
            var prefix = '';
            if(importDev.deviceType==4){
                prefix = '9999';
            }else if(importDev.deviceType==3){
                prefix = '8888';
            }
            $(".deviceCheckBox").each(function(i,box) {
                if((box!=null && box.checked)&&($(box).attr("data-status")=="false")){
                    idList+=prefix+$(box).attr("data-imei")+",";
                }
            });
        }
        if(idList.length>1){
            console.log()
            suixun.confirm_noTit("是否回收该设备？",function (data) {
                if(data){
                        idList=idList.substring(0,idList.length-1);
                        var param="param={";
                        param = getJsonDataNotEmpty(param,"imei",'"'+idList+'"');
                        if(importDev.deviceType == 1){
                            param = getJsonDataNotEmpty(param,"type",'1');
                        }else{
                            param = getJsonDataNotEmpty(param,"type",'2');
                        }
                        param += "}";
                        suixun.ajax(serverUrl+'/deviceInitManage/recycleDevice.json',param,"get",function(data){
                            suixun.hideLoding(200);//隐藏加载中
                            if(data.code == 200){
                                suixun.alert('回收成功！',function (data) {
                                    if(data){
                                        svar.onPageClick(currentpage);
                                    }
                                })
                            }else{
                                suixun.alert(data.msg);
                            }
                        });
                }
            });
        }else{
            suixun.alert("请选择已投放的设备");
            return false;
        }
    },
    render: function () {
        {
            var svar = this;
            var onClickArray = [this.onClickEdit,this.onClickDelete,this.onClickList,this.onClickAll];
            var onMoutArray = [this.onMouseOverList,this.onMouseOutList,this.onClickBachIdList];//onClickBachIdList 是点击左侧列表
            var listDatas = listData.map(function (data,index) {
                return (
                    <ListDate key={index} listNumber={index} onClickList={onClickArray[2].bind(svar,[data.batchid,listData.length])} onMouseOutList={onMoutArray[1].bind(svar,data.batchid)} onMouseOverList={onMoutArray[0].bind(svar,data.batchid)} onClickDelete={onClickArray[1].bind(svar,data.id)} onClickEdit={onClickArray[0].bind(svar,[data.id,data.batchid])} onClickAll={onClickArray[3].bind(svar,["",listData.length])}
                              id={data.id} batchid={data.batchid} />
                )
            });
            var Tabels;
            if(importDev.deviceType=="1"){
                if(otherData.boxOrdevice == "box"){
                    Tabels = deviceData.map(function (data,index) {
                        return (
                            <DeviceBox key={index} id={data.boxid} listNumber={index} devicetype={data.devicetype}  factory={data.factory}  boxid={data.boxid}  batchid={data.batchid}  schoolname={data.schoolname}  status={data.status} imei={data.imei} devicecounts={data.devicecounts} />
                        )
                    })
                }else{
                    Tabels = deviceData.map(function (data,index) {
                        return (
                            <Device key={index} id={data.id} listNumber={index} simid={data.simid} devicetype={data.devicetype}  factory={data.factory}  boxid={data.boxid}  batchid={data.batchid}  schoolname={data.schoolname}  status={data.status} imei={data.imei}  devicecounts={data.devicecounts} />
                        )
                    })
                }
            }else if(importDev.deviceType=="2"){//赛丰
                Tabels = saifenData.map(function (data,index) {
                    return (
                        <SFDevice key={index} id={data.id} listNumber={index} devicetype={data.devicetype}  factory={data.factory}  telephone={data.telephone}  schoolname={data.schoolname}  status={data.status} imei={data.imei}  devicecounts={data.devicecounts} />
                    )
                })
            }else if(importDev.deviceType=="4" ){//2.4G考勤卡
                Tabels = tpfData.map(function (data,index) {
                    return (
                        <KQKDevice key={index} id={data.id} listNumber={index} devicetype={data.devicetype}  factory={data.factory} schoolname={data.schoolname}  status={data.status} cardid={data.cardid}  devicecounts={data.devicecounts} />
                    )
                })
            }else if(importDev.deviceType=="3"){//13.56考勤卡
                Tabels = tpfxData.map(function (data,index) {
                    return (
                        <KQKDevice key={index} id={data.id} listNumber={index} devicetype={data.devicetype}  factory={data.factory} schoolname={data.schoolname}  status={data.status} cardid={data.cardid}  devicecounts={data.devicecounts} />
                    )
                })
            }
            //导入设备
            var importTabels = importDevData.map(function (data,index) {
                return (
                    <ImportDevTable key={index} factory={data.factory} listNumber={index} mdtid={data.mdtid}  fee={data.fee}  fee2={data.fee2} batchid={data.batchid} boxid={data.boxid} cardid={data.cardid} schoolname={data.schoolname} telephone={data.telephone} />
                )
            })
        }
        return (
            <div className="deviceDelivery tableManage-body">
                <div className="clearfix" style={{display:importDev.isImportDev==true?"none":"block"}}>
                    <div className="leftList">
                        <div className="list-query">
                                <span className="input-span">
                                    <input className="list-input-content enterEvent" onChange={this.onChangBatchInput} onClick={this.onClickBatch} data-list="batchList"  placeholder="输入批号搜索" type="text" maxLength="50" name="batchcode" id="batchcode"/>
                                </span>
                            <img onClick={this.onClickQueryImg} src="../img/icon/query.png" />
                            <div className="batchList schoolList" data-inputId="batchcode" >
                                {
                                    batchDataAll.map(function (data) {
                                        return (
                                            <span onClick={onMoutArray[2]} className="batchList-value schoolList-value">{data.batchid}</span>
                                        )
                                    })
                                }
                            </div>
                        </div>
                        <div className="list-show-total">
                            <span className="list-number-span" style={{cursor:"default"}}>全部(<span className="listTotal">{allDeviceCount}</span>)</span>
                        </div>
                        <div className="list-data">
                            <div className="list-data-div" onClick={this.onClickDevice} data-deviceType="4">2.4G考勤卡</div>
                            <div className="list-data-div" onClick={this.onClickDevice} data-deviceType="3">13.56考勤卡</div>
                            <div className="list-data-div" onClick={this.onClickDevice} data-deviceType="2">赛丰智能学生证</div>
                            <div className="list-data-div-wxb list-data-div select" onMouseMove={this.onMouseMoveWxb} onMouseOut={this.onMouseOutWxb} ><div onClick={this.onClickDevice} id="weixb" data-deviceType="1" style={{float:"left"}}>卫小宝智能学生证</div><span className="wxbAdd" onClick={this.onClickAddBatch} >添加</span></div>
                            <div className="list-data-div-ul">
                                <ul className="list-data-ul">
                                    {listDatas}
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div className="rightTable">
                        <Addbatchnumber onClockSaveAddbatchnumber={this.onClockSaveAddbatchnumber} />
                        <AddEquipment otherData={this.otherData} onPageClick={this.onPageClick} queryAllDevice={this.queryAllDevice}/>
                        <FastDelivery onPageClick={this.onPageClick} />
                        <PutDelivery onPageClick={this.onPageClick} />
                        <ExcelInput excelInput={this.excelInput}/>
                        <ImportRepeat />
                        <header >
                            <div className="header-left">
                                <input type="hidden" name="device-status" id="device-status" />
                                <input type="hidden" name="device-batchid" id="device-batchid" />
                                <input type="hidden" name="showtype" id="showtype" />
                                <div className="header-left-select droup-select left-droup-select" style={{display:importDev.deviceType=="1"?"block":"none"}}>
                                    <div className="election-value left-election-value" >{otherData.boxOrdevice == "box"?'按箱号':'按设备'}</div>
                                    <span className="lower-right-corner" />
                                    <div className="drop-down left-drop-down" >
                                        <span className="select-value" style={{lineHeight: "30px"}} onClick={this.onClickCategory}>按箱号</span>
                                        <span className="select-value" style={{lineHeight: "30px"}} onClick={this.onClickCategory}>按设备</span>
                                    </div>
                                </div>
                                <div className="header-left-number">
                                    <span className="header-left-batchid">{otherData.batchNumber}</span>
                                    <span className="header-left-batchid-number">{deviceCount}</span>
                                    <span className="header-left-unit">{otherData.boxOrdevice == "box"?'箱':'台'}</span>
                                </div>
                            </div>
                            <div className="header-right " style={{right: "-10px"}}>
                                <div className="header-right-select droup-select">
                                    <div className="school-or-table">学校</div>
                                    <span className="lower-right-corner dropDownImg"/>
                                    <div className="drop-down query-drop" style={{top: '2px'}}>
                                        <span className="select-value school-name" style={{lineHeight:'25px'}}>学校</span>
                                        <span className="select-value student-name" style={{lineHeight:'25px'}} >IMEI号</span>
                                    </div>
                                </div>
                                <div className="header-right-query" style={{marginRight:otherData.boxOrdevice == "box"?'0px':'-10px'}}>
                                    <div className="header-right-query-input">
                                        <input className="queryVal enterEvent" type="text" onChange={this.onChangSchoolInput} onClick={this.onClickDropQuery} data-list="schoolname_search"  name="schoolname_search" id="schoolname_search" maxLength="50" placeholder="请输入学校关键词"/>
                                    </div>
                                    <div className="header-right-query-img" onClick={this.onClickQuerySchoolName}></div>
                                    <div className="schoolList schoolname_search " data-inputId="schoolname_search">
                                        {
                                            schoolDataList.map(function (data) {
                                                return (
                                                    <span className="schoolList-value" onClick={svar.onClickQuerySchoolList}>{data.schoolname}</span>
                                                )
                                            })
                                        }
                                    </div>
                                </div>
                                <div style={{width:'80px',right: '-10px',display:otherData.boxOrdevice == "box"?'none':'block'}} className="addButton" onClick={this.onClickQueryLastDev}>最后入库</div>
                                <div style={{width:'60px'}} className="addButton" onClick={this.onClickRecovery}>回收</div>
                                <div style={{marginRight: '0px',width: "90px"}} className={importDev.deviceType=="1"?(otherData.boxOrdevice == "box"?'hidden':'header-left-select droup-select right-droup-select'):"header-left-select droup-select right-droup-select"}>
                                    <div className="election-value right-election-value">筛选</div>
                                    <span className="lower-right-corner" style={{left: "65px"}} />
                                    <div className="drop-down right-drop-down" style={{height: "86px"}}>
                                        <span className="select-value" style={{lineHeight:"26px",fontSize:"14px"}} onClick={this.onClickIsPutIn} data-status="99">全部</span>
                                        <span className="select-value" style={{lineHeight:"26px",fontSize:"14px"}} onClick={this.onClickIsPutIn} data-status="1">已投放</span>
                                        <span className="select-value" style={{lineHeight:"26px",fontSize:"14px"}} onClick={this.onClickIsPutIn} data-status="-1">未投放</span>
                                    </div>
                                </div>
                                <div style={{marginRight: '0px'}} className={otherData.boxOrdevice == "box"?'hidden':'addButton'} onClick={this.onClickPutInEquipment}>
                                    <span className="addButton-img"><img src="../img/icon/delivery.png" /></span>
                                    <span className="addButton-text">投放</span>
                                </div>
                                <div style={{marginRight: '22px'}} className={otherData.boxOrdevice == "box"?'hidden':'addButton '} onClick={this.onClickAddEquipment}>
                                    <span className="addButton-img"><img src="../img/icon/add-white.png" /></span>
                                    <span className="addButton-text">新增</span>
                                </div>
                                <div style={{width:"100px"}} className={otherData.boxOrdevice == "box"?'hidden':'export '}   onClick={this.onClickImportExport}>
                                    <span className="export-img"><img src="../img/icon/import.png" /></span>
                                    <span className="export-text">批量导入</span>
                                </div>

                                <div style={{right:"10px"}} className={importDev.deviceType=="1"?(otherData.boxOrdevice == "box"?'addButton fastDelivery':'hidden'):"hidden"} onClick={this.onClickSpeedinessPutIn}>
                                    <span className="addButton-img"><img src="../img/icon/fastDelivery.png" /></span>
                                    <span className="addButton-text">快速投放</span>
                                </div>
                            </div>
                        </header>
                        <div className="studentsInfo tableInfo">
                            <div className="studentsInfo-data tableInfo-data">
                                <div className="studentsInfo-data-table tableInfo-data-table" >
                                    <table className="head-body head-body">
                                        <thead className={importDev.deviceType=="1"?(otherData.boxOrdevice == "box"?'':'hidden'):"hidden"}>
                                            <th style={{width: '3%'}}><input type="checkbox" className="boxParentCheckBox"/></th>
                                            <th style={{width: '10%'}}>序号</th>
                                            <th style={{width: '10%'}}>设备类型</th>
                                            <th style={{width: '10%'}}>生产商</th>
                                            <th style={{width: '15%'}}>箱号</th>
                                            <th style={{width: '15%'}}>投放状态</th>
                                            <th style={{width: '15%'}}>投放对象</th>
                                            <th style={{width: '15%'}}>装箱量</th>
                                        </thead>
                                        <thead className={importDev.deviceType=="1"?(otherData.boxOrdevice == "box"?'hidden':''):"hidden"}>
                                            <th style={{width: '3%'}}><input type="checkbox" className="deviceParentCheckBox"/></th>
                                            <th style={{width: '8%'}}>序号</th>
                                            <th style={{width: '10%'}}>设备类型</th>
                                            <th style={{width: '8%'}}>生产商</th>
                                            <th style={{width: '10%'}}>设备IMEI号</th>
                                            <th style={{width: '8%'}}>设备手机号</th>
                                            <th style={{width: '8%'}}>投放状态</th>
                                            <th style={{width: '15%'}}>投放对象</th>
                                            <th style={{width: '15%'}}>批号</th>
                                            <th style={{width: '8%'}}>箱号</th>
                                        </thead>
                                        <thead className={importDev.deviceType=="2"?"":"hidden"}>
                                            <th style={{width: '3%'}}><input type="checkbox" className="deviceParentCheckBox"/></th>
                                            <th style={{width: '10%'}}>序号</th>
                                            <th style={{width: '10%'}}>设备类型</th>
                                            <th style={{width: '10%'}}>生产商</th>
                                            <th style={{width: '10%'}}>设备IMEI号</th>
                                            <th style={{width: '10%'}}>投放状态</th>
                                            <th style={{width: '15%'}}>投放对象</th>
                                            <th style={{width: '15%'}}>设备手机号</th>
                                        </thead>
                                        <thead className={importDev.deviceType=="4"?"":"hidden"}>
                                            <th style={{width: '3%'}}><input type="checkbox" className="deviceParentCheckBox"/></th>
                                            <th style={{width: '5%'}}>序号</th>
                                            <th style={{width: '10%'}}>设备类型</th>
                                            <th style={{width: '10%'}}>生产商</th>
                                            <th style={{width: '10%'}}>考勤卡号</th>
                                            <th style={{width: '10%'}}>投放状态</th>
                                            <th style={{width: '15%'}}>投放对象</th>
                                        </thead>
                                        <thead className={importDev.deviceType=="3"?"":"hidden"}>
                                            <th style={{width: '3%'}}><input type="checkbox" className="deviceParentCheckBox"/></th>
                                            <th style={{width: '5%'}}>序号</th>
                                            <th style={{width: '10%'}}>设备类型</th>
                                            <th style={{width: '10%'}}>生产商</th>
                                            <th style={{width: '10%'}}>考勤卡号</th>
                                            <th style={{width: '10%'}}>投放状态</th>
                                            <th style={{width: '15%'}}>投放对象</th>
                                        </thead>
                                        <tbody className="delivery-body">
                                        {Tabels==""?'':Tabels}
                                        </tbody>
                                    </table>
                                    {Tabels==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                                </div>
                            </div>
                            <Page otherData={otherData} onPageClick={this.onPageClick} />
                        </div>
                    </div>
                    {
                        /**
                         * <footer id="copyright">
                         <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                         </footer>
                         */
                    }
                    <footer id="copyright">
                        <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                    </footer>
                </div>
                <div className="clearfix" style={{display:importDev.isImportDev==false?"none":"block"}}>
                    <header >
                        <div className="header-left">
                            <div style={{marginRight: '0px'}} className="addButton" onClick={this.onClickReturn}>
                                <span className="addButton-img"><img style={{position: "relative",top: "6px"}} src="../img/icon/fanhui.png" /></span>
                                <span className="addButton-text">返回</span>
                            </div>
                        </div>
                        <div className="header-right ">
                            <div className="addButton" style={{width:'105px'}} onClick={this.onClickRevoke}>
                                <span className="addButton-img" style={{left: "-34px"}}><img src="../img/icon/gotOut.png" /></span>
                                <span className="addButton-text" style={{width:'75px'}} >全部撤销</span>
                            </div>
                        </div>
                    </header>
                    <div className=" tableInfo">
                        <div className="studentsInfo-data tableInfo-data">
                            <div className="studentsInfo-data-table tableInfo-data-table" >
                                <table className="head-body ">
                                    <thead>
                                        <th style={{width: '5%'}}>序号</th>
                                        <th style={{width: '10%'}}>生产商</th>
                                        <th style={{width: '10%'}}>IMEI</th>
                                        <th style={{width: '10%'}}>设备价格</th>
                                        <th style={{width: '10%'}}>套餐价格</th>
                                        <th style={{width: '10%'}}>批号</th>
                                        <th style={{width: '10%'}}>箱号</th>
                                        <th style={{width: '10%'}}>考勤卡号</th>
                                        <th style={{width: '15%'}}>学校</th>
                                        <th style={{width: '10%'}}>设备手机号</th>
                                    </thead>
                                    <tbody >
                                        {importDevData==""?'':importTabels}
                                    </tbody>
                                </table>
                                {importDevData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                            </div>
                        </div>
                        <Page otherData={otherData} onPageClick={this.onPageClick} />
                    </div>
                    {
                        /**
                         * <footer id="copyright">
                         <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                         </footer>
                         */
                    }
                    <footer id="copyright">
                        <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                    </footer>
                </div>
            </div>
        )
    }
});
/**
 * 批量导入
 * @type {*}
 */
var ExcelInput = React.createClass({
    //关闭弹出层
    onClickHidePop: function () {
        $("#inputExcelName").val("");
        $("#file").val("");
        $(".excelInput").hide();
    },
    //选择Excel文件
    onChangFile: function () {
        var fileUrl = $("#file").val().split('\\');//注split可以用字符或字符串分割
        var fileName = fileUrl[fileUrl.length-1];//这就是要取得的图片名称
        var fileLat = fileName.substring( fileName.lastIndexOf('.')+1 );//后缀名称
        if(fileLat == "xls" || fileLat == "xlsx" ){
            $(".file_name").val(fileName);
        }else{
            suixun.alert("请选择Excel文件上传!",function (data) {
                if(data){
                    $(".file_name").val("");
                }
            });
        }
    },
    render: function () {
        return (
            <div  className="pop popPhone excelInput popModel">
                <div className="model"></div>
                <div className="pop-info popModel-info excelInput-info">
                    <div className="pop-title popModel-title ">
                        <span className="pop-title-content popModel-title-content">
                            <span className="pop-title-content-solid-left popModel-title-content-solid-left" style={{width:"180px "}} />
                                批量导入
                            <span className="pop-title-content-solid-right popModel-title-content-solid-right"  style={{width:"180px "}} />
                        </span>
                        <span className="pop-title-img popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                    </div>

                    <div className="pop-body popModel-body">
                        <div className="popModel-body-input">
                            <span className="popModel-body-input-title" style={{width: "108px",lineHeight:"41px",backgroundPosition:"106px 0px"}}>选择Excel文件</span>
                            <form name="excelInputForm" id="excelInputFrom"  enctype="multipart/form-data" method="post">
                                <input className="file_name input-content export-imei" id="inputExcelName" type="text" name="filename" readOnly="readOnly"/>
                                <a href="javascript:;" className="file">选择文件
                                    <input type="file" onChange={this.onChangFile}  name="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.ms-excel,application/vnd.ms-excel,application/vnd.ms-excel,application/vnd.ms-excel " id="file" />
                                </a>
                            </form>
                        </div>


                    </div>
                    <div className="popModel-button" style={{marginTop:"20px"}}>
                        <span className="popModel-button-ok" onClick={this.props.excelInput}>导入</span>
                    </div>
                </div>
            </div>
        );
    }
});
/**
 * 查看导入数据重复弹出层弹出层
 * @type {*}
 */
var ImportRepeat = React.createClass({
    onClickHidePop: function () {
        $(".popPhone").hide();
    },
    render: function () {
        {
            var importRepeatDatas = "";
            if(otherData.importRepeatType =="1"){
                /**
                 * 智能学生证
                 */
                importRepeatDatas = importRepeatData.map(function (data,index) {
                    return (
                        <tr style={{height: "36px"}}>
                            <td style={{width: '10%'}}>{parseInt(index)+1}</td>
                            <td style={{width: '30%'}}>{data.mdtid}</td>
                            <td style={{width: '30%'}}>{data.batchid}</td>
                            <td style={{width: '30%'}}>{data.boxid}</td>
                        </tr>
                    )
                }.bind(this));
            }else{
                /**
                 * 考勤卡
                 */
                importRepeatDatas = importRepeatData.map(function (data,index) {
                    return (
                        <tr style={{height: "36px"}}>
                            <td style={{width: '30%'}}>{parseInt(index)+1}</td>
                            <td style={{width: '70%'}}>{data.cardid}</td>
                        </tr>
                    )
                }.bind(this));
            }
        }
        return (
            <div className="pop popPhone popModel popImportRepeat ">
                <div className="model"></div>
                <div className="pop-info popModel-info popPhone-info">
                    <div className="pop-title popPhone-title">
                        <span className="pop-title-content popPhone-title-content">
                            <span className="pop-title-content-solid-left popPhone-title-content-solid-left"/>
                                设备导入重复数据
                            <span className="pop-title-content-solid-right popPhone-title-content-solid-right"/>
                        </span>
                        <span className="pop-title-img popPhone-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        <input type="hidden" name="batch_id" id="batch_id"/>
                    </div>
                    <div className="pop-body ">
                        <div className="tableInfo importRepeatTableInfo">
                            <div className="studentsInfo-data tableInfo-data">
                                <div className="studentsInfo-data-table tableInfo-data-table" >
                                    <table className="head-body ">
                                        {
                                            otherData.importRepeatType =="1"?
                                                <thead>
                                                    <th style={{width: '20%',height: "10px"}}>序号</th>
                                                    <th style={{width: '30%',height: "30px"}}>设备IMEI号</th>
                                                    <th style={{width: '30%',height: "30px"}}>批号</th>
                                                    <th style={{width: '30%',height: "30px"}}>箱号</th>
                                                </thead>
                                            :
                                                <thead>
                                                    <th style={{width: '30%',height: "10px"}}>序号</th>
                                                    <th style={{width: '70%',height: "30px"}}>考勤卡号</th>
                                                </thead>
                                        }
                                        <tbody >
                                        {importRepeatData==""?'':importRepeatDatas}
                                        </tbody>
                                    </table>
                                    {importRepeatData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                                </div>
                            </div>
                        </div>
                    </div>
                    <div className="messagePrompt" >注：以上为此次导入重复数据，其他数据已导入成功!</div>
                </div>
            </div>
        );
    }
});
/**
 * 父组件
 * @type {*}
 */
var Main = React.createClass({
    //组件初始状态
    getInitialState: function () {
        return {
            otherData:this.props.otherData,
            deviceData:this.props.deviceData,
            allDeviceCount:this.props.allDeviceCount,
            deviceCount:this.props.deviceCount,
            schoolData:this.props.schoolData,
            importDevData:this.props.importDevData,
            importDev:this.props.importDev,
            saifenData:this.props.saifenData,
            tpfData:this.props.tpfData,
            tpfxData:this.props.tpfxData,
            batchDataAll:this.props.batchDataAll,
            deviceManufactorData:this.props.deviceManufactorData,
            importRepeatData:this.props.importRepeatData,
            schoolDataList:this.props.schoolDataList,
            schoolDataAll:this.props.schoolDataAll
        }
    },
    componentDidMount: function () {
        this.onClickDeviceDelivery();
        this.queryAllDevice();
        suixun.ajax(serverUrl+'/schoolManage/querySchool.json','',"get",function(data){
            if(data.code == 200 ){
                for(var i=0;i<data.info.length;i++){
                    var obj=data.info[i];
                    schoolDataList[i] = {key:i,id:obj.id,schoolname:obj.schoolname};
                }
                schoolDataAll = schoolDataList;
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }else{
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }
        });
        //绑定回车时间
        var svar = this;
        $(document).keypress(function(e) {
            var eCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (eCode == 13){
                if($("#batchcode").is(":focus")){
                    svar.refs.getOnClickQueryImg.onClickQueryImg();
                }else if($("#schoolname_search").is(":focus")){
                    svar.refs.getOnClickQueryImg.onClickQuerySchoolName();
                }
            }
        });
    },
    /**
     * 查询所有的设备
     * 新增、导入、撤销会调用
     */
    queryAllDevice: function () {
        var svar = this;
        suixun.ajax(serverUrl+'/deviceInitManage/countAllDevice.json','',"get",function(data){
            if(data.code == 200){
                allDeviceCount=data.info.devicerows;
                svar.setState({allDeviceCount:allDeviceCount});
            }
        });
    },
    /**设备投放
     * 先查询左侧批号列表，然后查询投放需要的学校信息、在查询卫小宝所有设备 最后在一起this.setState()
     */
    onClickDeviceDelivery: function () {
        suixun.showLoding();//显示加载中
        deviceData = [];
        saifenData = [];
        tpfData = [];
        tpfxData = [];
        var param="param={";
        param = getJsonDataNotEmpty(param,"batchid",$("#device-batchid").val());
        if($("#device-status").val() != "99"){
            param = getJsonDataNotEmpty(param,"status",$("#device-status").val());
        }
        param = getJsonDataNotEmpty(param,"showtype","1");
        if($(".school-or-table").html() == '学校'){
            param = getJsonDataNotEmpty(param,"schoolname",'"'+$("#schoolname_search").val()+'"');
        }else{
            param = getJsonDataNotEmpty(param,"imei",'"'+$("#schoolname_search").val()+'"');
        }
        param = getJsonDataNotEmpty(param,"pagecount",pagecount+"");
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/deviceInitManage/queryDeviceInitList.json',param,"get",function(data){
            //清空选择框
            $(".deviceParentCheckBox").attr("checked",false);
            $(".boxCheckBox").attr("checked",false);
            $(".deviceCheckBox").attr("checked",false);
            if(data.code == 200){
                for(var i=0;i<data.info.queryresult.length;i++){
                    var obj=data.info.queryresult[i];
                    deviceData[i] = {id:obj.id,devicetype:obj.devicetype,simid:obj.simid,factory:obj.factory,imei:obj.imei,status:obj.status,schoolname:obj.schoolname,batchid:obj.batchid,boxid:obj.boxid,devicecounts:obj.devicecounts};
                }
                var pageRight = 0;
                if(data.info.totlepage > currentpage){
                    pageRight = 1;
                }
                otherData = {maxHeight:height,currentpage:1,totlepage:data.info.totlepage,totlerows:data.info.totlerows,pageLeft:0,pageRight:pageRight,view:'deviceDelivery',boxOrdevice:"device",batchNumber:'',upBatchNumber:''};
                totlepage = data.info.totlepage;boxOrdevice="device";//初始化的时候赋值：分页的当前页和总的页数

                deviceCount=data.info.totlerows;
                svar.setState({deviceData:deviceData,otherData:otherData,deviceCount:deviceCount,saifenData:saifenData,tpfData:tpfData,tpfxData:tpfxData});
            }
            listData = [];
            //查询批号
            param="param={";
            param = getJsonDataNotEmpty(param,"batchid",$("#batchid").val());
            param += "}";
            suixun.ajax(serverUrl+'/batchManage/queryBatch.json',param,"get",function(data){
                suixun.hideLoding(500);//隐藏加载中
                if(data.code == 200){
                    for(var i = 0;i<data.info.length;i++){
                        var obj=data.info[i];
                        listData[i] = {id:obj.id,batchid:obj.batchid};
                    }
                    svar.setState({listData:listData});
                }
                //查询学校
                param="param={";
                param = getJsonDataNotEmpty(param,"pagenumber","1");
                param = getJsonDataNotEmpty(param,"pagecount","1000");
                param += "}";
                suixun.ajax(serverUrl+'/schoolManage/querySchoolList.json',param,"get",function(data){
                    if(data.code == 200){
                        for(var i=0;i<data.info.queryresult.length;i++){
                            var obj=data.info.queryresult[i];
                            schoolData[i] = {id:obj.id,schoolname:obj.schoolname};
                        }
                        svar.setState({schoolData:schoolData});
                    }
                });
            });
        });
        //查询设备生产商
        // suixun.ajax(serverUrl+'/queryFactorys.json','',"get",function(data){
        //     for(var i=0;i<data.info.length;i++){
        //                var obj=data.info[i];
        //                deviceManufactorData[i] = {id:i,factory:obj.factory};
        //            }
        //            svar.setState({deviceManufactorData:deviceManufactorData});
        // });

    },
    //下载Excel模版
    excleModel: function () {
        suixun.confirm_noTit("是否导出Excel模版？",function (data) {
            if(data){
                window.location.href = serverUrl+"/deviceInitManage/export_DeviceTamplate.json";
            }
        });
    },
    render: function () {
        return (
            <div className="outside" >
                <div className="header-menu">
                    <ul>
                        <li><a href="../schoolManage/querySchoolList.html">学校</a></li>
                        <li onClick={this.onClickDeviceDelivery} className="select" >设备管理</li>
                        <li><a href="../simInfoManage/querySimInfoList.html">SIM卡管理</a></li>
                        <li style={{display:"none"}}><a href="../packageManage/queryPackageList.html">设备套餐</a></li>
                        <li style={{display:"none"}}><a href="../devicePriceManage/queryDevicePriceList.html">设备零售价</a></li>
                        <li><a href="../deviceonReserve/queryonReserveList.html">区域储备量</a></li>
                        <li><a href="../attendance/attendanceMange.html">考勤机管理</a></li>
                    </ul>
                    <div onClick={this.excleModel} className="excleModel" >
                        <img src="../img/icon/annotations.png" />
                        <span>导出Excel模版下载</span>
                    </div>
                </div>
                <DeviceDelivery onClickDeviceDelivery={this.onClickDeviceDelivery} queryAllDevice={this.queryAllDevice} ref="getOnClickQueryImg" />

            </div>
        );
    }
});
ReactDOM.render(
    <Main  otherData={otherData} deviceData={deviceData} schoolData={schoolData} allDeviceCount={allDeviceCount} deviceCount={deviceCount} importDevData={importDevData} saifenData={saifenData} tpfData={tpfData}
           tpfxData={tpfxData} deviceManufactorData={deviceManufactorData} importRepeatData={importRepeatData} schoolDataList={schoolDataList} schoolDataAll={schoolDataAll}/>,
    document.getElementById('tableManage')
);
//批号下拉列表
$("*").bind("click",function(e){
    var target = $(e.target);
    if(target.closest(".schoolList-value").length == 1){
        if("schoolname_search" == $(target.parent()).attr("data-inputId")){
            $("#"+$(target.parent()).attr("data-inputId")+"").val(target.html());
        }
        $(".schoolList").hide();
        $(".batchList").hide();
    }else if(target.closest(".batchList-value").length == 1){
        $(".schoolList").hide();
    }else{
        $(".batchList").hide();
        $(".schoolList").hide();
    }
});
//点击2.4G考勤卡、13.56、智能学生证
$(".list-data-div").click(function () {
    $(this).addClass(" select").siblings().removeClass(" select");
    $(".list-data-li").siblings().removeClass(" select");
});
//点击设备批号
$(".list-data-ul").on("click",".list-number",function () {
    $($(this).parent()).addClass(" select").siblings().removeClass(" select");
    $(".list-number-span").removeClass(" select");
    $(".list-data-div").siblings().removeClass(" select");
});
$(window).resize(function () {
    leftList();
});
$(function () {
    setTimeout(function () {
        leftList();
    },500);
    setTimeout(function () {
        leftList();
    },2000);
});
function leftList(){
    // console.log($(".delivery-body").height());
    // console.log($(window).height());
    // console.log($(".delivery-body").height() > $(window).height()-280);
    if($(".delivery-body").height() > $(window).height()-280){
        $(".list-data").css("height",$(".delivery-body").height()+40+"px");
        $(".leftList").css("height",$(".delivery-body").height()+130+"px");
        if($(".delivery-body").height() > 800){
            $("#copyright").css("bottom","-80px");
        }else{
            $("#copyright").css("bottom","5px");
        }
    }else{
        $(".list-data").css("height",$(window).height()-200+"px");
        $(".leftList").css("height",$(window).height()-113+"px");
    }
}

//删除时间区间
$(".time-father").on('click','.schoolDeleteTime',function () {
    $(this).parent().parent().remove();
});
/**
 * 点击箱号、批号下拉选项
 */
$(".left-droup-select").click(function () {
    $('.right-drop-down').slideUp();
    var dropDown = $(this).find('.left-drop-down');
    if(dropDown.is(":hidden")){
        dropDown.slideDown();
    }else{
        dropDown.slideUp();
    }
});
/**
 * 点击是否投放
 */
$(".right-droup-select").click(function () {
    $('.left-drop-down').slideUp();
    var dropDown = $(this).find('.right-drop-down');
    if(dropDown.is(":hidden")){
        dropDown.slideDown();
    }else{
        dropDown.slideUp();
    }
});
$(".parentCheckBox").click(function(){
    if($(".parentCheckBox").is(":checked")){
        $(".childrenCheckBox").prop("checked",true);
    }else{
        $(".childrenCheckBox").attr("checked",false);
    }
});
//设备管理-按箱号
$(".boxParentCheckBox").click(function(){
    if($(".boxParentCheckBox").is(":checked")){
        $(".boxCheckBox").prop("checked",true);
    }else{
        $(".boxCheckBox").attr("checked",false);
    }
});
//设备管理-按设备
$(".deviceParentCheckBox").click(function(){
    if($(".deviceParentCheckBox").is(":checked")){
        $(".deviceCheckBox").prop("checked",true);
    }else{
        $(".deviceCheckBox").attr("checked",false);
    }
});
//点击下拉框
$(".header-right-select").click(function () {
    var dropDown = $(this).find('.drop-down');
    if(dropDown.is(":hidden")){
        dropDown.slideDown();
    }else{
        dropDown.slideUp();
    }
});
//选择学校、卡号
$('.query-drop > span').click(function() {
    var value = $(this).html();
    $(".school-or-table").html(value);
    if(value == "学校"){
        $("#schoolname_search").val("");
        $("#schoolname_search").attr("placeholder","请输入"+$(this).html()+"关键词");
    }else if(value == "IMEI号"){
        $("#schoolname_search").val("");
        $("#schoolname_search").attr("placeholder","请输入"+$(this).html()+"关键字");
    }
    $('.query-drop').slideUp();
});